<template>
  <div>
    离开此页面之前将会提示
    <router-link to="/test/a10">to a10</router-link>
  </div>
</template>

<script>
export default {
  name: "Test4",
  beforeRouteLeave(to, from, next) {
    this.$confirm('页面上的数据尚未提交，是否切换页面?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      next();
    })
  }
}
</script>

<style scoped>

</style>